package com.lianniu.web.product.model;

public class Page {
    public int pageSize = 10;// 当前页一共有多少条
    // SqlSession session=MyBatisDBUtil.getSession();
    int nowpage = 1;// 当前页
    int maxpage = 0;// 最大页
    int minpage = 0;// 最小页
    int gopage = 1;// 去哪一个页面
    int nextpage = 0;// 下一页
    int purepage = 0;// 上一页
    int count = 0;// 总记录数
    int pageSum = 0;// 总页数
    int nowItem =0;
    public Page() {
        super();
    }

    public Page(int count, int gopage) {
        this.count = count;
        this.pageSum = this.getPageSum();
        this.setGopage(gopage);
        this.maxpage = this.getMaxpage();
        this.minpage = this.getMinpage();
        this.nowpage = gopage;
    }

    public Page(int count, int gopage, int pageSize) {
        this.count = count;
        this.pageSize = pageSize;
        this.pageSum = this.getPageSum();
        this.setGopage(gopage);
        this.maxpage = this.getMaxpage();
        this.minpage = this.getMinpage();
        this.nowpage = gopage;

    }

    /**
     * @return Returns the pageSize.
     */
    public int getPageSize() {

        if (this.count < this.pageSize) {
            return this.count;
        }
        return pageSize;
    }

    /**
     * @param pageSize
     *            The pageSize to set.
     */
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageSum() {
        if (this.getCount() % pageSize == 0) {
            return this.getCount() / pageSize;
        } else {
            return this.getCount() / pageSize + 1;
        }
    }

    public void setPageSum(int pageSum) {
        this.pageSum = pageSum;
    }

    public int getGopage() {
        return gopage;
    }

    public void setGopage(int goPage) {
        if (goPage < 1) {
            this.gopage = 1;
        } else {
            this.gopage = goPage;
        }
        if (gopage > this.getPageSum()) {
            this.gopage = this.getPageSum();
            this.nowpage = this.gopage;
            // System.out.println("this.gopage"+this.gopage);
        } else {
            this.nowpage = this.gopage;
            // System.out.println("this.gopage"+this.gopage);
        }
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getNowpage() {
        return nowpage;
    }

    public void setNowpage(int nowpage) {
        this.nowpage = nowpage;
    }

    public int getMaxpage() {

        return gopage * this.getPageSize();
    }

    public void setMaxpage(int maxpage) {
        this.maxpage = maxpage;
    }

    public int getMinpage() {

        return (gopage - 1) * pageSize + 1;
    }

    public void setMinpage(int minpage) {
        this.minpage = minpage;
    }

    public int getNextpage() {
        if (this.nowpage + 1 > this.pageSum) {
            return this.pageSum;
        } else {
            return this.nowpage + 1;
        }

    }

    public void setNextpage(int nextpage) {
        this.nextpage = nextpage;
    }

    public int getPurepage() {
        if ((this.nowpage - 1) == 0) {
            return 1;
        } else {
            return this.nowpage - 1;
        }

    }

    public void setPurepage(int purepage) {
        this.purepage = purepage;
    }

    public int getNowItem() {
        return nowpage*pageSize;
    }

    public void setNowItem(int nowItem) {
        this.nowItem = nowItem;
    }
    
}
